#include <stdio.h>
#include <string.h>
int main()
{
	char start[201];
	scanf("%s",&start);
	int len=sizeof(start);
	int count=0,stop_num;
	for(int i=0;i<201;i++)
	{
		if(start[i]=='/')
		{
			count++;
			stop_num=i;
		}
	}
	char operate[201];
	scanf("%s",&operate);
	if(operate=="cd /")
	{
		printf("/");
	}
	if(operate=="cd..")
	{
		for(int j=stop_num;j>=0;j--)
		{
			start[j]='0';
			if(start[j]=='/')
			break;
		}
	}
	if(operate[3]=='/'&&operate[4]!=0)
	{
		printf("%s",operate);
	}
    if(operate[3]!='/'&&operate[3]!='.')
    {
    	strcpy(start,operate);
	}
	return 0;
	
}
